(* Mathematica package *)

(*Incidence medium 0 to interface v*)
InternalTransferC["PartialSTC", "0-","v-'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := tTOP[AbelesSIv]/denomv[AbelesSIv, PhaseMv, AbelesSIIv];
InternalTransferC["PartialSTC", "0-","v+'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := (tTOP[AbelesSIv] rTOP[AbelesSIIv] (PhaseMv[[1, 1]])^(-2))/ denomv[AbelesSIv, PhaseMv, AbelesSIIv];
InternalTransferC["PartialSTC", "0-","v-", SIvm1_, Phivm1_, SIIvm1_] := (tTOP[SIvm1] Phivm1[[2, 2]])/ denomv[SIvm1, Phivm1, SIIvm1];
InternalTransferC["PartialSTC", "0-","v+", SIvm1_, Phivm1_, SIIvm1_] := (tTOP[SIvm1] rTOP[SIIvm1] Phivm1[[2, 2]])/ denomv[SIvm1, Phivm1, SIIvm1];

(*Incidence medium k+1 to interface v *)
InternalTransferC["PartialSTC", "kp1+'","v-'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := (tBOT[AbelesSIIv] rBOT[AbelesSIv] (PhaseMv[[1, 1]])^(-1))/ denomv[AbelesSIv, PhaseMv, AbelesSIIv];
InternalTransferC["PartialSTC", "kp1+'","v+'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := (tBOT[AbelesSIIv] (PhaseMv[[1, 1]])^(-1))/ denomv[AbelesSIv, PhaseMv, AbelesSIIv];
InternalTransferC["PartialSTC", "kp1+'","v-", SIvm1_, Phivm1_, SIIvm1_] := (tBOT[SIIvm1] rBOT[SIvm1] (Phivm1[[1, 1]])^(-2))/ denomv[SIvm1, Phivm1, SIIvm1];
InternalTransferC["PartialSTC", "kp1+'","v+", SIvm1_, Phivm1_, SIIvm1_] := tBOT[SIIvm1]/ denomv[SIvm1, Phivm1, SIIvm1]


(*Internal Transfer Coefficients, calculate from Subsystem II*)

(*Incidence from medium 0 (First)*)
InternalTransferC["SII", "0-", "v-'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := Block[{PhiSIIv=PhaseMv.AbelesSIIv},tTOP[(*S*)AbelesSIv.PhiSIIv] (PhiSIIv)[[1, 1]]];
InternalTransferC["SII", "0-", "v+'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := Block[{PhiSIIv=PhaseMv.AbelesSIIv},tTOP[(*S*)AbelesSIv.PhiSIIv] (PhiSIIv)[[2, 1]]];
InternalTransferC["SII", "0-", "v-", SIvm1_, Phivm1_, SIIvm1_] := tTOP[(*S*)SIvm1.Phivm1.SIIvm1] SIIvm1[[1, 1]];
InternalTransferC["SII", "0-", "v+", SIvm1_, Phivm1_, SIIvm1_] := tTOP[(*S*)SIvm1.Phivm1.SIIvm1] SIIvm1[[2, 1]];

(*Incidence from medium k+1 (Last)*)
InternalTransferC["SII", "kp1+'", "v-'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := Block[{PhiSIIv=PhaseMv.AbelesSIIv},(PhiSIIv.{rBOT[(*S*)AbelesSIv.PhiSIIv], 1})[[1]]];
InternalTransferC["SII", "kp1+'", "v+'", AbelesSIv_, PhaseMv_, AbelesSIIv_] := Block[{PhiSIIv=PhaseMv.AbelesSIIv},(PhiSIIv.{rBOT[(*S*)AbelesSIv.PhiSIIv], 1})[[2]]];
InternalTransferC["SII", "kp1+'", "v-", SIvm1_, Phivm1_, SIIvm1_] := (SIIvm1.{rBOT[(*S*)SIvm1.Phivm1.SIIvm1], 1})[[1]];
InternalTransferC["SII", "kp1+'", "v+", SIvm1_, Phivm1_, SIIvm1_] := (SIIvm1.{rBOT[(*S*)SIvm1.Phivm1.SIIvm1], 1})[[2]];

(*Paired Evaluation for Increased Execution Speed*)
InternalTransferC["0-","vBottomSide",AbelesSIv_, PhaseMv_, AbelesSIIv_] := Block[{PhiSIIv=PhaseMv.AbelesSIIv},PhiSIIv .{tTOP[(*S*)AbelesSIv.PhiSIIv],0}](*[[All,1]]*);
InternalTransferC["0-","vTopSide",SIvm1_,Phivm1_,SIIvm1_] := SIIvm1 . {tTOP[(*S*)SIvm1.Phivm1.SIIvm1],0};
InternalTransferC["kp1+'","vBottomSide",AbelesSIv_, PhaseMv_, AbelesSIIv_] := Block[{PhiSIIv=PhaseMv.AbelesSIIv},(PhiSIIv.{rBOT[(*S*)AbelesSIv.PhiSIIv], 1})];
InternalTransferC["kp1+'","vTopSide", SIvm1_, Phivm1_, SIIvm1_] := SIIvm1.{rBOT[(*S*)SIvm1.Phivm1.SIIvm1], 1};

InternalTransferC[args___]/;Message[General::badargs,InternalTransferC[args]]:="unevaluated"
